<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        div {
            text-align: center;
        }

        table {
            margin: 0 auto
        }
    </style>
</head>

<body>
    <div id="app">
        <h4>欢迎光临_vue开发的收银系统_水果店</h4>
        <table border="1" width="600" height="100">
            <caption>
                苹果{{price}}￥/斤，折扣<{{discount}}折>
            </caption>
            <tbody>
                <tr>
                    <td>
                        <span>请输入你要购买的斤数</span>
                        <input type="number" v-model.number="name" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <button @click="btn">结账买单</button>
                    </td>
                </tr>
            </tbody>
        </table>
        <p>结账单· 总价· {{num}}￥元 折后价· {{discount1}} ￥元 省了· {{sun}}￥元</p>
    </div>
    <script src="../vue.js"></script>

    <script>
        const app = new Vue({
            el: '#app',
            data: {
                name: 0,
                price: 10,
                discount: 8,
                discount1: 0,
                num: 0,
                sun: 0
            },
            methods: {
                btn() {
                    // console.log(12)
                    this.num = this.name * this.price
                    this.discount1 = this.name * this.discount
                    this.sun = (this.name * this.price) - (this.name * this.discount)
                }
            }
        })


    </script>
</body>

</html>